<template>
    <div>
        <div class="log-item">日志管理</div>
        <div v-for="log in logs" class="log-item">
            <el-tag type="success" effect="dark" round @click="openLogDetail(log)">
                {{ log }}
            </el-tag>
        </div>
    </div>
</template>

<script setup>
const baseUrl = ref(import.meta.env.VITE_APP_BASE_API);
import { ref, onMounted } from "vue";
import api from "@/api";
import { useRouter } from "vue-router";
const router = useRouter();
const logs = ref([]);

const openLogDetail = (log) => {
    const logUrl = `${baseUrl.value}logs/${log}`;
    window.open(`${logUrl}`, "_blank");
};

onMounted(() => {
    api.logs.getLogs().then((res) => {
        logs.value = res.logs;
    });
});
</script>

<style scoped>
.log-item {
    margin: 20px;
}
</style>
